package com.blue.base.shiro;

import com.blue.base.shiro.api.ShiroAuthService;
import com.blue.base.shiro.constants.ShiroConfigBean;
import com.blue.base.shiro.realms.AuthRealms;
import com.blue.base.shiro.util.ShiroUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * shiro自动化配置
 *
 * @author liulei
 * @version 1.0
 */
@Slf4j
@Configuration
@EnableConfigurationProperties(ShiroConfigBean.class)
@ConditionalOnProperty(name = "sys.auth.enabled")
public class ShiroAutoConfig {

    public ShiroAutoConfig(){
        log.info("==========初始化Shiro模块==========");
    }

    @Bean
    public AuthRealms authRealms(ShiroUtil shiroUtil, ShiroAuthService shiroAuthService) {
        return new AuthRealms(shiroUtil, shiroAuthService);
    }

}
